/*
 * =====================================================================================
 *
 *       Filename:  lander.h
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  22.01.2010 12:01:09
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Michal Antonczak (uzyszkodnik), uzyszkodnik.priv@gmail.com
 *        Company:  
 *
 * =====================================================================================
 */

#pragma once
#include "timer.h"
#include "wektor.h"
#include "gamestructs.h"
#include <SDL/SDL.h>
#include "sdlstuff.h"
#include "moonlander.h"
#include	"particles.h"

#define SHIP_CRASHED 0
#define SHIP_OK 1
#define SHIP_LANDED 2
using namespace std;
class Lander{
	private:
		ParticleEngine *pengine;
		SDL_Surface* collision_map;

		Wektor dv,v;
		//img of our lander
		SDL_Surface* img;
		SDL_Surface* lander_tmp;		
		SDL_Surface* communicate;
		
		//description of the mighty force pushing our lil ship
		Wektor  engine_force; 
		//speed of the ship	
		Wektor  momentum;
	
		/*
			Here's going some suff i've created having in mind frame-independent movement
			basically we can't handle the real ship position in int because when the frame drawing takes
			around 0.001s the position calculated via speed*time will be rounded to null
		*/

		//position of the ship in the space	
		SDL_Rect position_int;	
		SDL_Rect engine_position;
		//the real position in the space

		struct position position_float;

		//that's the answer why physic engine should be independent....	

		struct physic_consts *phys;			
		struct ship* ship_info;
		//movement timer
	//	Timer c_timer;

		//description of the ship		

		/*
		float mass;
		float fuel;		
		float fuel_mass;
		*/
		double angle;	

		//draw rotation
		void rotate();
		// physic handling funcs
		
		// time to calculate lander pos mon
		void calculatepos(); 

		//do we collide with terrain?
		void collision();
		TTF_Font* font;
		SDL_Color textColor;
		bool landed();		
		void calculate_fuel_usage();
		struct position_i* map_info;
		void hud();

	public:
		//angle between the ship and earth
		int state;
		Lander(SDL_Surface* scr, SDL_Surface* cm, struct physic_consts* p, struct ship *si, struct position_i* mi);

		~Lander();

		//function showing lander on the screen
		//old one
//		void show();
		//what happened to the ship during the frame
		void frame();

		//control stuff

		//engine stuff, basically we decide either is it working or not	
		void incengine();
		void stopengine();
		
		void rotate_right();
		void rotate_left();


		friend class Moonlander;

};

